package com.youku.controls
{
   import com.youku.plugins.ads.ADFacade;
   import com.youku.events.PluginEvent;
   import com.youku.GlobalService;
   import com.youku.GlobalServiceKeys;
   
   public class ADController extends BasePluginController
   {
      
      public function ADController() {
         super();
         this._adFacade = ADFacade.getInstance();
         this._adFacade.init(viewManager.adLayer,playerProxy);
         GlobalService.addService(GlobalServiceKeys.AD_PLAYER_FACADE,this._adFacade);
         playerProxy.addEventListener(PluginEvent.AD_PLAY_COMPLETE,this.onADEvent);
         playerProxy.addEventListener(PluginEvent.AD_LOAD_COMPLETE,this.onADEvent);
         playerProxy.addEventListener(PluginEvent.AD_READY_OR_ERROR,this.onADEvent);
         playerProxy.addEventListener(PluginEvent.AD_ADPOINT_LOADED,this.onADEvent);
         playerProxy.addEventListener(PluginEvent.AD_REQUEST_TO_PLAY,this.onADEvent);
         playerProxy.addEventListener(PluginEvent.AD_REQUEST_TO_RESUME,this.onADEvent);
         playerProxy.addEventListener(PluginEvent.AD_SOUND_MUTE,this.onADEvent);
         playerProxy.addEventListener(PluginEvent.AD_GET_FOCUS,this.onADEvent);
         playerProxy.addEventListener(PluginEvent.AD_LOST_FOCUS,this.onADEvent);
      }
      
      private var _adFacade:ADFacade;
      
      private function onADEvent(param1:PluginEvent) : void {
         facadeManager.processADEvent(param1);
      }
   }
}
